package com.fsoft.core.aop;

import org.apache.shiro.authz.AuthorizationException;
import org.aspectj.lang.ProceedingJoinPoint;

import com.fsoft.core.utils.RetVo;

/**
 * 异常处理切面：
 * @author Fish
 * @date 2021-04-12
 * @email it.fish2010@foxmail.com
 * @copyright ©2015-2021
 * @Company 广西自贸区佳成软件有限责任公司
 */
public class BaseAspectException {
	/***
	 * 具有返回值的异常处理
	 * @author Fish
	 * @date 2021-04-12
	 * @param joinPoint
	 * @return
	 */
	public RetVo returnRetVoSytemException(ProceedingJoinPoint joinPoint) {
		try {
			return (RetVo) joinPoint.proceed();
		} catch (Throwable e) {
			return RetVo.error(e.getMessage());
		}
	}

	/***
	 * 页面跳转的监听
	 * @author Fish
	 * @date 2021-04-18
	 * @param joinPoint
	 * @return
	 */
	public String returnStringException(ProceedingJoinPoint joinPoint) {
		try {
			return (String) joinPoint.proceed();
		} catch (Throwable e) {
			if (e instanceof AuthorizationException)
				return "/fsoft-web/noAuth";
			return "/fsoft-web/404";
		}
	}
}
